<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Models\CouponType;

class InitCouponType extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'InitCouponType';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        CouponType::where('id', '>', 0)->delete();

        $couponTypes = [
            [
                'code' => 'HSH_BK01',
                'name' => '家庭保洁面积61-80平米',
                'mode' => 1, // 服务兑换券
                'product_id' => 1,
                'price' => 800.00
            ],
            [
                'code' => 'HSH_BK02',
                'name' => '燃气热水器清洗服务',
                'mode' => 1, // 服务兑换券
                'product_id' => 2,
                'price' => 128.00
            ],
            [
                'code' => 'HSH_BK03',
                'name' => '家用烟灶套餐（油烟机+燃气灶）清洗',
                'mode' => 1, // 服务兑换券
                'product_id' => 3,
                'price' => 218.00
            ],
            [
                'code' => 'HSH_BK04',
                'name' => '家庭雾化消毒灭菌服务121-160平米（含氯消毒剂）',
                'mode' => 1, // 服务兑换券
                'product_id' => 4,
                'price' => 488.00
            ]
        ];
        foreach($couponTypes as $couponType) {
            CouponType::create($couponType);
        }
        $this->info('init cardtype finished!');
        return 0;
    }
}
